class GripperController:
    def __init__(self, ts):
        super().__init__()

        self._ts = ts
        self._tf = 0.05
        self._x = 255

    def get(self):
        return self._x

    def open(self):
        self._x += 255 * self._ts / self._tf
        arrive = False
        if self._x >= 255:
            self._x = 255
            arrive = True
        return arrive, self._x

    def close(self):
        self._x -= 255 * self._ts / self._tf
        arrive = False
        if self._x <= 0:
            self._x = 0
            arrive = True
        return arrive, self._x
